//#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "KeyboardHandler.h"
#include "Settings.h"

#include "../situationControl/SituationController.h"

/* constructor */
KeyboardHandler::KeyboardHandler( int num , SituationController *mSC) {
	num_keys = num;
	keys =(unsigned char *)malloc(num);
	mSituationController = mSC;
}

void KeyboardHandler::read_settings( FILE * fp ) {
	mySettings.get_keys(fp);
}


/* key handler function. makes higher level calls depending on settins, key */
void KeyboardHandler::key_pressed(unsigned char key, int x, int y) {
  //printf("Key: %c pressed at x:%d y:%d\n\n",key,x,y);
    if(key == mySettings.forward)
       mSituationController->advanceForward();
    if(key == mySettings.reverse)
	mSituationController->advanceBackward(); 
    if(key == mySettings.up)
	mSituationController->turnUp();
    if(key == mySettings.down)
	mSituationController->turnDown();
    if(key == mySettings.right)
	mSituationController->turnRight();
    if(key == mySettings.left)
	mSituationController->turnLeft();
    if(key == mySettings.fire)
	mSituationController->fire();
1; 
}

